<template>
  <router-view />
</template>

<script>
import './assets/global.css';
import router from './router/index.js';
export default {
  name: 'App',
  components: {},
  data() {
    return {
      user: JSON.parse(sessionStorage.getItem('User')),
      menu: JSON.parse(sessionStorage.getItem('Menu')),
    };
  },
  // watch: {
  //   '$store.state.menu': {
  //     handler(val, old) {
  //       if (!old && this.user && this.user.account) {
  //         console.log('okapp');
  //         this.$store.dispatch('updateMenu', val);
  //         console.log(this.menu);
  //       }
  //     },
  //     immediate: true,
  //   },
  // },
};
// if (user != null) {
//   router.push('/Index');
// } else {
//   this.$router.push('/');
// }
// const useraccount = JSON.stringify(sessionStorage.getItem('User')).account;
// if (useraccount) {
//   console.log('1');
//   if (to.path === '/') {
//     console.log('1-1');
//     router.push({ path: '/Index' });
//   } else {
//     let routes = await this.$store.commit('', this.$store.menu);
//     routes.forEach((item) => router.addRoute(item));
//     router.push({ ...to, replace: true });
//   }
// } else {
//   console.log('2');
//   router.push({ path: '/' });
// }

const debounce = (fn, delay) => {
  let timer = null;
  return function () {
    let context = this;
    let args = arguments;
    clearTimeout(timer);
    timer = setTimeout(function () {
      fn.apply(context, args);
    }, delay);
  };
};

const _ResizeObserver = window.ResizeObserver;
window.ResizeObserver = class ResizeObserver extends _ResizeObserver {
  constructor(callback) {
    callback = debounce(callback, 16);
    super(callback);
  }
};
</script>

<style>
#app {
  height: 100%;
}
</style>
